import { VNode, CreateElement, RenderContext } from 'vue'
import { InjectOptions, PropsDefinition } from 'vue/types/options'

// 事件处理
export type EventHandler = (event: Event) => void

// 对象索引
export type ObjectIndex = Record<string, any>

// 单个作用域插槽
export type ScopedSlot<Props = any> = (
  props?: Props
) => VNode[] | VNode | undefined

// 默认插槽
export type DefaultSlots = {
  default?: ScopedSlot;
}

// 作用域插槽对象
export type ScopedSlots = DefaultSlots & {
  [key: string]: ScopedSlot | undefined
}

// model 映射配置
export type ModelOptions = {
  prop?: string;
  event?: string;
}

// 默认属性
export type DefaultProps = ObjectIndex;

// 函数组件
export type FunctionComponent<Props = DefaultProps, PropDefs = PropsDefinition<Props>> = {
  (
    h: CreateElement,
    props: Props,
    slots: ScopedSlots,
    context: RenderContext<Props>
  ): VNode | undefined
  props?: PropDefs
  model?: ModelOptions
  inject?: InjectOptions
}
